package com.rpay.dao.reptile;

import com.google.common.collect.Maps;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import java.util.Map;

/**
 * Title：
 * Description
 *
 * @author fxg06 on 2018/5/6
 * @version 1.0
 */
@Repository
public class ReptileDao {
    
    @Autowired
    @Qualifier("readSqlSession")
    private SqlSessionTemplate readSqlSession;

    @Autowired
    @Qualifier("writeSqlSession")
    private SqlSessionTemplate writeSqlSession;

    public int insert(String channel, String url, String content) {
        Map<String, String> map = Maps.newHashMap();
        map.put("channel", channel);
        map.put("url", url);
        map.put("content", content);
        return writeSqlSession.insert("rpay.reptile.insert", map);
    }

    public String select(String channel) {
        return readSqlSession.selectOne("rpay.reptile.select", channel);
    }
}
